package com.ai.mall.controller.admin;

import com.ai.mall.entity.OrderItemsEntity;
import com.ai.mall.service.OrderItemsService;
import com.ai.mall.utils.PageUtils;
import com.ai.mall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 订单详情表
 *
 * @author easue
 * @email sunlightcs@gmail.com
 * @date 2025-01-21 14:40:34
 */
@RestController
@RequestMapping("mall/orderitems")
public class OrderItemsController {
    @Autowired
    private OrderItemsService orderItemsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("mall:orderitems:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderItemsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{itemId}")
    //@RequiresPermissions("mall:orderitems:info")
    public R info(@PathVariable("itemId") Integer itemId){
		OrderItemsEntity orderItems = orderItemsService.getById(itemId);

        return R.ok().put("orderItems", orderItems);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mall:orderitems:save")
    public R save(@RequestBody OrderItemsEntity orderItems){
		orderItemsService.save(orderItems);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mall:orderitems:update")
    public R update(@RequestBody OrderItemsEntity orderItems){
		orderItemsService.updateById(orderItems);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mall:orderitems:delete")
    public R delete(@RequestBody Integer[] itemIds){
		orderItemsService.removeByIds(Arrays.asList(itemIds));

        return R.ok();
    }

}
